<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <!-- <el-button
          :style="istxChange ? 'background-color: #409eff;color: white;' : ''"
          icon="el-icon-edit"
          size="mini"
          @click="getistxChange"
          type="info"
          >快捷编辑</el-button
        > -->
      </el-col>

      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          
          >修改</el-button
        >
      </el-col> -->
    </el-row>
    <el-table :data="productCodeList">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->

      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="分配类型" align="center" prop="allocType" />
      <el-table-column label="商品类型" align="center" prop="productType" />
      <el-table-column label="商品编码" align="center" prop="productCode" />
      <el-table-column label="上架ID" align="center" prop="shelfId" />
      <el-table-column label="店铺" align="center" prop="storeName" />
      <el-table-column label="数量" align="center" prop="quantityCount" />
      <el-table-column label="退货比例" align="center" prop="ratio" />
      <el-table-column
        label="计算分配数量"
        align="center"
        prop="allAllocationCount"
      >
        <template slot-scope="scope">
          <el-input-number
            v-model="scope.row.allAllocationCount"
            placeholder="计算分配数量"
            v-if="istxChange === true"
          />
          <span v-else>{{ scope.row.allAllocationCount }}</span>
        </template>
      </el-table-column>
    </el-table>

    <div style="width: 100%; text-align: center">
      <el-button style="margin-top: 12px" @click="prev">上一步</el-button>
      <el-button style="margin-top: 12px" @click="next">关闭</el-button>
    </div>
  </div>
</template>

<script>
import {
  getShopReturnNumAndAndCalc,
  getShopReturnNumAndAndCalcList,
} from "@/api/productAllocation/BiProductReturnRestock";
import { abnormalTaskProcess } from "@/api/productAllocation/task";
export default {
  //   components: { KoiCardI },
  props: {
    row: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      istxChange: false,
      productCodeList: [],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
    };
  },
  watch: {
    row: {
      handler: function (newnew, oldold) {
        // console.log("newnew", newnew);
        if (this.row.length > 0) {
          this.getList();
        }
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    getList() {
      getShopReturnNumAndAndCalcList(this.row).then((response) => {
        this.productCodeList = response;
      });
    },

    getistxChange() {
      this.istxChange = !this.istxChange;
    },
    prev() {
      //   this.handleStatusChange();
      this.$emit("prev");
    },
    next() {
      // this.handleStatusChange();
      this.$emit("next");
    },
    handleStatusChange() {
      var list = [];
      this.productCodeList.forEach((item) => {
        list.push({
          storeName: item.storeName,
          storeItemQuantity: item.allAllocationCount,
        });
      });
      let obj = {
        ...this.row,
        shopsAllocatNumber: list,
      };
      abnormalTaskProcess(obj).then((response) => {
        if (response.code == 200) {
          this.$modal.msgSuccess("修改成功");
          this.istxChange = false;
          this.getList();
        }
      });
    },
  },
};
</script>

<style>
</style>
String storeName;   //店铺名字
    long quantityCount;   //退货总数量
    Double ratio;         //退货比例
    long allAllocationCount;//计算分配数量